﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MISAPP.Classify.Service;

public partial class View_MIS_ARTM95_EXCEL : ViewMatrix //System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string para;
        para = Request.QueryString["para"];
        if (!Utility.IsDateYM(para))
        {
            if (para.Equals("budget"))
            {
                setBudget();
            }
            return;            
        }
        else
        {
            setARTM();
        }

    }

    protected void setBudget()
    {
        serviceName = "MISAPP.Classify.Service.Service_Squared";
        getData("Squared2Excel");
    }

    protected void setARTM()
    {
        /*
         * para = YYYYMM
         * bg = 大版塊
         * sm = 小版塊
         * br = 分行
         * cr = 幣別
         * mthd = Data Object 這一個Method
         */
        //也許這個陣列應該要放在service layer吧??
        //string[] paraCollect = { "para", "bg", "sm", "br", "cr", "mthd" };
        //第一個是method name
        //第二個是參數

        /*
        serviceName = "MISAPP.Classify.Service.Service_ARTM95_ABCDE";
        System.Collections.ArrayList al = new System.Collections.ArrayList();
        foreach (string qryString in Request.QueryString)
        {
            al.Add(Request.QueryString[qryString]);
        }

        string method;
        method = "GetDataFromWeb";//Request.QueryString["mthd"];
        criteriaList = new string[] { "Criteria" };
        Session["Criteria"] = al;
        System.Data.DataTable dt = GetDataFromSerevice(method);
        gv1.DataSource = dt;
        gv1.DataBind();        
         */
        serviceName = "MISAPP.Classify.Service.Service_ARTM95_ABCDE";
        getData("GetDataFromWeb");
    }

    protected void getData(string p_method)
    {        
        System.Collections.ArrayList al = new System.Collections.ArrayList();
        foreach (string qryString in Request.QueryString)
        {
            al.Add(Request.QueryString[qryString]);
        }

        criteriaList = new string[] { "Criteria" };
        Session["Criteria"] = al;
        System.Data.DataTable dt = GetDataFromSerevice(p_method);
        gv1.DataSource = dt;
        gv1.DataBind();            
    }
}
